const Router = require("koa-router");
const {
  webLogin,
  getUserList,
  createUser,
  logout,
  deleteUser,
} = require("../controller/webUser.controller");
const { crpytPassword } = require("../middleware/user.middleware");
const { auth } = require("../middleware/auth.middleware");
const webUserRouter = new Router({ prefix: "/webUser" });

webUserRouter.get("/", (ctx, next) => {
  // ctx.router available
  ctx.body = "hello webuser";
});
// 创建用户
webUserRouter.post("/createUser", crpytPassword, createUser);

// 用户登录
webUserRouter.post("/login", webLogin);

// 获取用户信息
webUserRouter.get("/getUserInfo", auth);

// 获取用户列表
webUserRouter.get("/getUserList", auth, getUserList);

// 删除用户
webUserRouter.post("/removeUser", auth, deleteUser);

//修改密码
// userRouter.post("/updatePwd", auth, crpytPassword, updatePwd);

// 退出登录
webUserRouter.get("/logout", auth, logout);

module.exports = webUserRouter;
